package com.vates.login.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.vates.login.dao.UserDAO;
import com.vates.login.model.User;


@Repository("userDao")
public class UserDAOImpl extends GenericDaoHibernate<User, Long> implements UserDAO {

	public UserDAOImpl() {
		super(User.class);
	}

	@Override
	public User getUser(String userName) {
        @SuppressWarnings("unchecked")
		List<User> users = this.hibernateTemplate.findByNamedParam("from User where username = :username", 
        		"username", userName);
        
        if (users.isEmpty())
        	return null;
        else
        	return users.get(0);
	}

	
}
